home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7297 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  46 lines

  1. Path: news.cc.sunysb.edu!math!stefan
  2. From: stefan@math.sunysb.edu (Stefan Gromoll)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Arrow keys in DOS
  5. Date: 22 Feb 1996 16:29:35 GMT
  6. Organization: SUNY at Stony Brook, Dept. of Math
  7. Message-ID: <4gi5lf$omn@abel.cc.sunysb.edu>
  8. References: <312A7CDB.7010@wolfenet.com>
  9. NNTP-Posting-Host: math-gw.pi.sunysb.edu
  10.  
  11. In article <312A7CDB.7010@wolfenet.com> Michael Gooding <mgooding@wolfenet.com> writes:
  12. >How would one go about trapping and interpreting arrow keys in a DOS 
  13. >program written in BC++ 4.5
  14.  
  15.  
  16. Michael,
  17.  
  18. each arrow key sends two values- the first signifies an extended key,
  19. and the second signifies the key itself.  I think the secondary values
  20. of the keys are like 70-74 or so.  You can write a simple program to
  21. find these out:
  22.  
  23. main()
  24. {
  25.  
  26.     int first, second;
  27.     
  28.     first = getch();    // in conio.h i think?
  29.     second = getch();
  30.  
  31.     cout << "Extended character value: " << first << endl;
  32.     cout << "Value for arrow key: " << second << endl;
  33. }
  34.  
  35.  
  36. Its rough code, but something like that should work.  So when you're
  37. testing input and find the extended character value, just use another
  38. getchar to get the value of the arrow key, and then test that.
  39.  
  40. I hope my explanation hasn't been too confusing {:)
  41.  
  42.         -stefan
  43.  
  44. --
  45. stefan@math.sunysb.edu
  46.